package com.wish.contract.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wish.common.core.usconfig.common.MsgResult;
import com.wish.common.security.annotation.RequiresPermissions;
import com.wish.contract.entity.SfContract;
import com.wish.contract.entity.vo.SfContractVo;
import com.wish.contract.service.ISfContractService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 高露雯-收房合同表 前端控制器
 * </p>
 *
 * @author gaoluwen
 * @since 2022-03-26
 */
@RestController
@RequestMapping("/contract/sf-contract")
public class SfContractController {
    @Autowired
    ISfContractService iSfContractService;

    /**
     * @description 搜索合同表列表
     * @author gaoluwen @date 2022-03-26 9:57
     * @param :
     * @return {@link }
     * @Throws
    */
    @RequiresPermissions("contract:contract:sf-contract:searchContractList")
    @GetMapping("searchContractList")
    public MsgResult searchContractList(SfContractVo sfContractVo){
        PageHelper.startPage(sfContractVo.getPageNum(),sfContractVo.getPageSize());
        List<SfContract> list = iSfContractService.searchContractList(sfContractVo);
        PageInfo<SfContract> info = new PageInfo<>(list);
        //分页
        /*Page<SfContract> page = new Page<>(sfContractVo.getPageNum(),sfContractVo.getPageSize());
        PageInfo<SfContract> info = new PageInfo<>(page);
        info.setList(list);*/

        return MsgResult.succeed(info);
    }

    //导入还款计划
    /*@PostMapping("uploadRepaymentPlan")
    public MsgResult uploadRepaymentPlan(RequestInsertPayDto insertPayDto, HttpServletRequest request, HttpServletResponse response){
        StandardServletMultipartResolver standardServletMultipartResolver = new StandardServletMultipartResolver();
        MultipartHttpServletRequest multipartHttpServletRequest = standardServletMultipartResolver.resolveMultipart(request);
        MultipartFile file = multipartHttpServletRequest.getFile("upfile");

        if(file.isEmpty()){
            return MsgResult.fail(400,"文件不存在!",null);
        }

        //执行InsertPayment方法,导入付款单

        return MsgResult.succeed();
    }*/
}
